home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Form & Validation / max-of-words.izs < prev    next >
Text File  |  2005-08-29  |  2KB  |  62 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>Max # of words check 
  4. <!/TITLE>
  5.  
  6. <!DESCRIPTION>A script that checks the number of words in a form box, and if it exceeds the predetermined number, cancels the form submission, and asks the surfer to re-enter data. This script requires NS 3.x, 4.x, or IE 4.x to function-all other browsers will simply not participate in the word checking.
  7. <!/DESCRIPTION> 
  8.  
  9. <!CATEGORY>form and form validation<!/CATEGORY>
  10.  
  11. <!SCRIPT>
  12. <!-- START OF SCRIPT -->
  13. <script>
  14. <!--
  15. function checkwords(cur){
  16. //change max # of words to determine below
  17. var maxwords=10
  18. if (document.images){
  19. var temp=cur.words.value.split(" ")
  20. if (temp.length>maxwords){
  21. alert("Please restrain your input to 10 or less words!")
  22. return false
  23. }
  24. }
  25. }
  26. //-->
  27. </script>
  28.  
  29. <form onsubmit="return checkwords(this)">
  30. <strong>In 10 words or less, please tell us your qualifications:</strong><br><textarea rows="5" cols="38" name="words"></textarea>
  31. <br><input type="submit" value="Submit!">
  32. </form>
  33. <!-- END OF SCRIPT -->
  34. <!/SCRIPT>
  35.  
  36. <!PREVIEW>
  37. <!-- START OF SCRIPT -->
  38.  
  39. <script>
  40. <!--
  41. function checkwords(cur){
  42. //change max # of words to determine below
  43. var maxwords=10
  44. if (document.images){
  45. var temp=cur.words.value.split(" ")
  46. if (temp.length>maxwords){
  47. alert("Please restrain your input to 10 or less words!")
  48. return false
  49. }
  50. }
  51. }
  52. //-->
  53. </script>
  54.  
  55. <form onsubmit="return checkwords(this)">
  56. <strong>In 10 words or less, please tell us your qualifications:</strong><br><textarea rows="5" cols="38" name="words"></textarea>
  57. <br><input type="submit" value="Submit!">
  58. </form>
  59. <!-- END OF SCRIPT -->
  60. <!/PREVIEW>
  61.  
  62. <!RELATED>NONE<!/RELATED>